<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use DB;
class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        $pData = DB::table('types')
                -> where('pid',0)
                -> get();
                // dd($pData);
         //二级列表
         $list = [];
         foreach ($pData as $key => $value)
         {
           $list[$value -> tid] = DB::table('types')
                ->where('pid',$value -> tid)
                ->get();
         }
         view()->share('pData' , $pData);
         view()->share('list' , $list);
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }
}
